package com.shqcjd.sinopecdemomobile.ui.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.shqcjd.sinopecdemomobile.R;
import com.shqcjd.sinopecdemomobile.model.pojo.OfflineProblemBean;
import com.shqcjd.sinopecdemomobile.util.DateUtil;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by sy on 2019/5/14.
 */

public class OfflineProblemAdapter extends BaseQuickAdapter<OfflineProblemBean,OfflineProblemAdapter.ViewHolder> {

    public OfflineProblemAdapter() {
        super(R.layout.item_offline_problem_list);
    }

    @Override
    protected void convert(OfflineProblemAdapter.ViewHolder helper, OfflineProblemBean item) {
        String imgurl = "";
        if (item.getImgs() != null && item.getImgs().size() > 0) {
            imgurl = item.getImgs().get(0);
        }


        RequestOptions options = new RequestOptions()
                .placeholder(R.mipmap.ic_default_small)	//加载成功之前占位图
                .error(R.mipmap.ic_default_small);	//加载错误之后的错误图
//                .override(87,87);//指定图片的缩放类型为centerCrop （等比例缩放图片，直到图片的宽高都
        Glide.with(mContext)
                .load(imgurl)
                .apply(options)
                .into(helper.iv_img);

        helper.tv_name.setText(""+item.getProjectName());
        helper.tv_info.setText(""+item.getProblemInfo());
        helper.tv_time.setText(""+ DateUtil.getDateToString(item.getTime(),"yyyy-MM-dd HH:mm:ss"));

        helper.addOnClickListener(R.id.right);
        helper.addOnClickListener(R.id.content);


    }

    class ViewHolder extends BaseViewHolder {
        @BindView(R.id.iv_img)
        ImageView iv_img;
        @BindView(R.id.tv_name)
        TextView tv_name;
        @BindView(R.id.tv_info)
        TextView tv_info;
        @BindView(R.id.tv_time)
        TextView tv_time;
        @BindView(R.id.right)
        LinearLayout right_del;
        @BindView(R.id.content)
        LinearLayout content;
        public ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }

}
